home *** CD-ROM | disk | FTP | other *** search
/ Technotools / Technotools (Chestnut CD-ROM)(1993).ISO / batch / delay / delay.mac < prev   
Encoding:
Text File  |  1985-08-14  |  2.0 KB  |  67 lines

  1. /*  DELAY - Delay for a period
  2.  
  3. $define(tag,$$segment(@1,$$index(@1,=)+1))#
  4. $define(version,Version $tag(
  5. TED_VERSION DB =1.04), created on $tag(
  6. TED_DATE DB =08/14/85) at $tag(
  7. TED_TIME DB =12:12:43))#
  8. $undefine(tag)#
  9.     $version
  10.  
  11. (C) COPYRIGHT 1985 by System Enhancement Associates; ALL RIGHTS RESERVED
  12.  
  13.     By:  Thom Henderson
  14.  
  15.     Description:
  16.          This program delays for a defined period of time, and then
  17.          terminates.  It is intended for use in batch files.
  18.  
  19.     Instructions:
  20.          Invoke this program with a statement of the form:
  21.  
  22.               delay <n>
  23.  
  24.          Where <n> is the decimal number of seconds to delay.  For example,
  25.          to delay for ten seconds, type:
  26.  
  27.               delay 10
  28.  
  29.     Language:
  30.          Computer Innovations Optimizing C86
  31. */
  32. #include <stdio.h>
  33.  
  34. int count = 0;                         /* countdown timer */
  35.  
  36. timer()                                /* timer tick routine */
  37. {
  38.     count--;                           /* decrement the counter */
  39. }
  40.  
  41. main(num,arg)                          /* system entry point */
  42. int num;                               /* number of arguments */
  43. char *arg[];                           /* pointers to arguments */
  44. {
  45.     int elev = 0;                      /* error level */
  46.  
  47.     if(num<2)
  48.          abort("Usage: delay <n>");
  49.  
  50.     count = atoi(arg[1]) * 18;         /* get delay counter */
  51.     intrinit(timer,0,0x1c);            /* take over timer interrupt */
  52.  
  53.     while(count>=0)                    /* wait for time to elapse */
  54.     {    if(!(count%18))               /* update display */
  55.               printf("Time: %d \r",count/18);
  56.          if(key_scan()!=EOF)           /* abort if requested */
  57.          {    if((key_getc()&0xff)==27)
  58.               {    elev = 1;
  59.                    break;
  60.               }
  61.          }
  62.     }
  63.  
  64.     intrrest(0x1c);                    /* give back timer interrupt */
  65.     return elev;
  66. }
  67.